<?php

class TopMethod extends RestMethod {
	
	public $type;
	
	public function rules() {
		return array(
			array('type', 'safe')
		);
	}
	
	
	function runInternal() {
		return 	$this->getTemplate($this->type);
	}
	
	protected function getTemplate($type) {
		$c = Yii::app();
		$loginUrl = $c->createUrl('/provide/index/login');
		$regUrl = $c->createUrl('/misc/regType');
		$missPwUrl = $c->createUrl('/misc/findpass');
		$helpUrl = $c->createUrl('/help/list');
		$logoutUrl = $c->createUrl('/provide/index/logout');
		
		$guest = <<<EOD
	<form action='{$loginUrl}' method='post'>
		<span>用户名：<input class='px vm' name='AdminLoginForm[username]' type='text' size=15></span>
		<span>密码：<input class='px vm' name='AdminLoginForm[password]' type='password' size=15></span>
		<span><button style="width: 65px;" class="pn vm" type="submit"><em>登录</em></button></span>
	</form>
EOD;
		
		$body = $type == 'guest' ? $guest : '';
		
		return <<<EOD
<div id='ly-login-form'>
	$body
	<span><a href="{$regUrl}">注册</a></span>
	<span><a href="{$missPwUrl}">忘记密码</a></span>
	<span><a href="{$helpUrl}">帮助</a></span>
</div>
EOD;

	}
	
	
}

?>